<?php


/**
 * @author Admin
 *
 *
 */
class ArticleDao extends ContentDao {
	const POPUPWidth=650;
	
	const POPUPHeight=570;
	//TODO - Insert your code here
	/***
	 * The root controller
	 */
	protected $controller;
	/***
	 * The model for loading image data
	 */
	protected $model;
	/**
	 * 
	 * 
	 * the editable text block
	 * @var unknown_type
	 */
	protected $editor;
	/**
	 * 
	 * Constructor
	 * @param unknown_type $action
	 */
	function __construct($action = FALSE) {
		$this->property_types = array_merge_recursive(
		$this->property_types,
		array(
                       'metadata' => array(
                                                 'type' => 'TEXT',
                                          		 'null' => TRUE
                                          )
                )
		);
		parent::__construct( $action );
		$this->controller = CI_Controller::get_instance();
		if($this->getObjects( )->size()>0){
			$children = $this->getObjects( );
			$this->editor = $children[0];
		}
		else {
			$this->editor = new EditableTextBlock($action );
			if($action){
				$this->addObject( $this->editor );
			}
		}
		
		//TODO - Insert your code here
	}

	/**
	 *
	 * @see ContentDao::GetEditorDisplay()
	 */
	public  function GetEditorDisplay() {
		$edit = $this->editor->Editor();
		return $edit;
		//TODO - Insert your code here
	}
	/**
	 * Gets a display for showing view with edit controls
	 * (non-PHPdoc)
	 * @see ContentDao::GetEditableDisplay()
	 */
	public function GetEditableDisplay(){
		$display = parent::GetEditableDisplay("",$this->editor->content);
		$display->section_type = ContentLineManager::ARTICLE;
		return $display->output->content;
	}
	
	/**
	 * 
	 * get the content for the section to view on the site
	 */
	public function GetDisplay(){
		if( (bool)$this->publishable ){
			$display = new Display();
			$display->base = "block";
			$display->id = "article$this->id";
			$display->class = "floatleft";
			$display->blockcontent= $this->editor->content;
			$display->finalize();
			return $display->output->content;
		}
		return "";
	}

}


?>